user_info={
    "userinfo":{
        "TQ_username": "cc9200",
         "TQ_password": "cc9200"
        },
    'IDtoExchange':{
         #上海
        "rb":'SHFE',"zn":'SHFE',"ag":'SHFE',"bu":'SHFE',"sp":'SHFE',
        "ss":'SHFE',"fu":'SHFE','ru':'SHFE', 'cu':'SHFE', 
        'al':'SHFE', 'ni':'SHFE', 'ag':'SHFE', 'hc':'SHFE', 
         'ao':'SHFE', 
        #大连
        "i":'DCE',"m":'DCE',"p":'DCE',"eg":'DCE',"l":'DCE',"v":'DCE',
        "pg":'DCE',"c":'DCE',"a":'DCE',"b":'DCE',"cs":'DCE',"eb":'DCE',
        "j":'DCE',"jm":'DCE',"pp":'DCE',"y":'DCE',
        #郑州
        "SR":'CZCE',"TA":'CZCE',"SA":'CZCE',"FG":'CZCE','CF':'CZCE',
        "MA":'CZCE','AP':'CZCE','JD':'CZCE','CJ':'CZCE','OI':'CZCE',
        'PF':'CZCE','PX':'CZCE','RM':'CZCE','SF':'CZCE','SR':'CZCE',
        'UR':'CZCE','ZC':'CZCE',
        #能源
        "lu":'INE',"nr":'INE',"sc":'INE',"ec":'INE',
        #广期所
        'si':'GFEX',"lc":'GFEX',
        },
    "IDtoMiniprice":{
                       "rb":1,"zn":5,"ag":1,"bu":1,"sp":2,"ss":10,"fu":1,'ru':5,  #上海
                        "i":0.5,"m":1,"p":2,"eg":1,"l":1,"v":1,"pg":1,"c":1,#大连
                        "SR":1,"TA":2,"SA":2,"FG":1,'CF':5,"MA":1,#郑州
                     
                    }
}

def getCode(InstrumentID):
    return InstrumentID[:2] if InstrumentID[1].isalpha() else InstrumentID[0]
def logicalOprator(num1,logicStr,num2):
    if logicStr ==">":
        return num1>num2
    elif logicStr =="<":
        return num1<num2
    elif logicStr ==">=":
        return num1>=num2
    elif logicStr =="<=":
        return num1<=num2
    else:
        raise ValueError('逻辑运算符错误')
# from tqsdk import Quote
def getCorrectTradePrice(quote,Direction="多"):
    if (quote.ask_price1-quote.bid_price1)/quote.price_tick==1.0:
            return quote.bid_price1 if quote.ask_volume1>quote.bid_volume1 else quote.ask_price1
    else:
        return quote.bid_price1+quote.price_tick if Direction=="多" else quote.ask_price1-quote.price_tick
# def checkToClose(CloseOrder,quote):
#     if logicalOprator(quote.last_price,CloseOrder['触发逻辑'],CloseOrder["触发价"]):
#         return 
    
import csv
order={
    '品种': 'v2405', 
    '触发价': '6012', 
    '多空': '空', 
    '开平': '开', 
    '手数':1,
    '触发逻辑': '>', 
    '止损点数': '0', 
    '止盈点数': '20', 
    '状态': 'NotOpen', 
    '创建时间': '1709298403.1816332'
    }
fieldnames=[
    '品种', 
    '触发价', 
    '多空', 
    '开平', 
    '手数',
    '触发逻辑', 
    '止损点数', 
    '止盈点数', 
    '状态', 
    '创建时间'
    ]

# CSVwriter.writerow(order)
CSVreader = csv.DictReader(open('./OrderTable.csv','r',encoding='gbk'))

for row in CSVreader:
    print(row)

# CSVwriter.close()